package edu.xidian.sselab.cloudcourse.controller;

import edu.xidian.sselab.cloudcourse.domain.test2_entity;
import edu.xidian.sselab.cloudcourse.repository.test2_Repository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.List;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class test2_controller {

    @Autowired
    private test2_Repository test2_repository;

    @RequestMapping("/test2")
    public String test2_try(Model model){
        model.addAttribute("title", "各个价格区间间的销量占比");
        return "test2";
    }

    @RequestMapping("/test18")
    public @ResponseBody
    List test2_try2() throws IOException {
        List<test2_entity> recordList = test2_repository.find();
        System.out.println("以下是各个价格区间的销售数据：");
        for(test2_entity t:recordList){
            System.out.println(t);
        }
        return recordList;
    }
}
